<%@ taglib prefix="spring-tags" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="spring-form" uri="http://www.springframework.org/tags/form"%>
<%@ page
    import="org.jiscinvolve.astrodabis.mallow.model.api.Tag"
    import="org.jiscinvolve.astrodabis.mallow.model.api.Query"
    import="org.jiscinvolve.astrodabis.mallow.model.api.QueryTag"
    import="org.jiscinvolve.astrodabis.mallow.model.api.Result"
    import="org.jiscinvolve.astrodabis.mallow.model.api.Account"
    import="org.jiscinvolve.astrodabis.mallow.model.tap.TapTable"
    import="org.jiscinvolve.astrodabis.mallow.model.tap.TapService"
    import="org.jiscinvolve.astrodabis.mallow.control.ViewData"
    session="true"
%>
<%@ include file="/jsp/init.jsp" %>
<%@ include file="/jsp/queries/init.jsp" %>
<html>
    <head>
	    <title>AstroDAbis create query</title>
        <link href='/astrodabis/css/page.css' rel='stylesheet' type='text/css'/>
    </head>
    <body>
        <%@ include file="/jsp/header.jsp" %>
        <div class='body'>
            <div class='left'>
                <%@ include file="/jsp/menu.jsp" %>
            </div>
            <div class='right'>
            </div>
            <div class='content'>
        	    <h2>New query for <%= actor.name() %></h2>

      			<spring-form:errors path="bean"/>
	            <spring-form:form method="post" modelAttribute="bean">

                    <fieldset>
                        <legend>Table</legend>
                        <div>
                      		<spring-form:select path="table">
                                <spring-form:option value="-" label="Select a table"/>
                                <%
                                for (TapTable table : actor.tables().select())
                                    {
                                    %>
                                    <spring-form:option value="<%= table.ident() %>" label="<%= table.service().name() + '.' + table.name() %>"/>
                                    <%
                                    }
                                %>
                      		</spring-form:select>
                  			<spring-form:errors path="table"/>
                        </div>
                    </fieldset>

                    <fieldset>
                        <legend>Name</legend>
                        <div>
                      		<spring-form:input  path="name"/>
                  			<spring-form:errors path="name"/>
                        </div>
                    </fieldset>
                    <fieldset>
                        <legend>Description</legend>
                        <div>
		              		<spring-form:textarea rows='3' cols='50' path="text"/>
	              			<spring-form:errors path="text"/>
                        </div>
                    </fieldset>

                    <fieldset>
                        <legend>ADQL where</legend>
                        <div>
		              		<spring-form:textarea rows='3' cols='50' path="where"/>
	              			<spring-form:errors path="where"/>
                        </div>
                    </fieldset>

			        <div>
			            <button name="save"   type="submit">Save</button>
			            <button name="run"    type="submit">Run</button>
		            </div>

    		    </spring-form:form>

            </div>
        </div>
        <%@ include file="/jsp/footer.jsp" %>
    </body>
</html>




